<template>
	<view>
		<!-- <view class="topTabs">
			<ms-tabs :list="tabs" v-model="defaultIndex"></ms-tabs>
		</view>
		<view style="height: 100rpx;"></view>
		<swiper class="swiper-box" :duration="100" :current="defaultIndex" :style="{height: swiperheight+'px'}" @change="swiperChange">
			<swiper-item>
				1
			</swiper-item>
			<swiper-item>
				2
			</swiper-item>
			<swiper-item>
				3
			</swiper-item>
			<swiper-item>
				4
			</swiper-item>
		</swiper> -->
		<!-- 简单样式 -->
		<view class="order-list">
			<view class="order-item" v-for="(v,index) in page.list" :key="index">
				<view class="flex flex-j-b">
					<view style="font-weight: 900;">订单编号：{{v.order_no}}</view>
					<view>￥{{v.total_price}}</view>
				</view>
				<!-- <view style="font-size: 28upx;">烧结砖---数量：1</view> -->
				<view style="font-size: 28upx;">{{v.pay_status=='0'?'待支付':'已支付'}}</view>
				<view style="font-size: 28upx;">{{v.is_send_out=='0'?'待发货':'已发货'}}</view>
				<!-- <view style="text-align: right;" v-if="v.pay_status=='0'">
					<button type="default" size="mini">立即付款</button>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import msTabs from '@/components/ms-tabs/ms-tabs.vue'
	export default {
		components:{msTabs},
		data() {
			return {
				tabs: [
					{
						title: '全部',
						id: '1',
					},
					{
						title: '待付款',
						id: '2',
					},
					{
						title: '待发货',
						id: '3',
					},
					{
						title: '已发货',
						id: '4',
					},
				],
				defaultIndex: 0,
				swiperheight:  100,
				
				page: {
					pageNumber: 1,
					firstPage: true,
					lastPage: true,
					list: [],
				},
				noMore: false,
			}
		},
		onReachBottom(){
			console.log('触底');
			if(this.page.lastPage) {this.noMore = true;return;}
			this.getDataMore(++this.page.pageNumber);
		},
		methods:{
			swiperChange(e){
				this.defaultIndex = e.detail.current;
			},
			getData(pageNumber){
				let self = this;
				uni.showLoading({title: '加载中',mask: true});
				this.config.post('/api/order/findPage', {
					pageNum: pageNumber?pageNumber:1,
				}).then(res=>{
					uni.hideLoading();
					if(res.data.code==='0'){
						self.page.pageNumber = res.data.page.pageNumber;
						self.page.firstPage = res.data.page.firstPage;
						self.page.lastPage = res.data.page.lastPage;
						self.page.list = res.data.page.list;
					}else{
						uni.showToast({title: self.config.handleError(res.data),icon: 'none'});
					}
				})
			},
			getDataMore(pageNumber){
				let self = this;
				uni.showLoading({title: '加载中',mask: true});
				this.config.post('/api/order/findPage', {
					pageNum: pageNumber?pageNumber:1,
				}).then(res=>{
					uni.hideLoading();
					if(res.data.code==='0'){
						self.page.pageNumber = res.data.page.pageNumber;
						self.page.firstPage = res.data.page.firstPage;
						self.page.lastPage = res.data.page.lastPage;
						self.page.list = self.page.list.concat(res.data.page.list);
					}else{
						uni.showToast({title: self.config.handleError(res.data),icon: 'none'});
					}
				})
			},
		},
		mounted() {
			this.getData()
		}
	}
</script>

<style lang="less" scoped>
	.order-item{
		margin: 20upx;
		padding: 20upx;
		box-shadow: 0 0 10upx 0 #999;
		border-radius: 10upx;
		line-height: 50upx;
	}
</style>
